package iteratorDesignPattern;

/**
 * @author Anitta
 * Concrete classes implementing the Container interface and responsible to implement Iterator interface and use it.
 */
import java.util.ArrayList;
import java.util.List;

import classes.Employee;
import facadeDesignPattern.Functions;

public class EmployeeRepository implements Container {
	public List<Employee> employee = new ArrayList<Employee>();

	public EmployeeRepository() {
		Functions f = new Functions();
		employee = f.read();
	}

	@Override
	public Iterator getIterator() {
		// TODO Auto-generated method stub
		return new EmployeeIterator();
	}

	private class EmployeeIterator implements Iterator {
		int index;

		@Override
		public boolean hasNext() {
			if (index < employee.size()) {
				return true;
			}
			return false;
		}

		@Override
		public Object next() {
			if (this.hasNext()) {
				return employee.get(index++);
			}
			return null;
		}
	}

}
